/***************************************************************************
 *  Copyright (c) 2005 Chih-Chung Chang                                    *
 *  Parts copyright (c) 2006 Michael Olson                                 *
 *  Copyright (C) 2007-2008 by Fehmi "Canavar" SAGLAM                      *
 *  canavar@fehmicans.net                                                  *
 *                                                                         *
 *  This file is part of sTerm.                                            *
 *                                                                         *
 *  sTerm is free software; you can redistribute it and/or modify          *
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation; either version 3 of the License, or      *
 *  (at your option) any later version.                                    *
 *                                                                         *
 *  sTerm is distributed in the hope that it will be useful,               *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>   *
 ***************************************************************************/

#include "../include/font.h"
#include "../include/stermbutton.h"

StermButton::StermButton( SDL_Surface *screen,
                          int row,
                          int col,
                          StermKey *stermKey,
                          int bg_color,
                          int fg_color
                         )
{
 this->screen = screen;
 this->row = row;
 this->col = col;
 this->stermKey = stermKey;  
 this->bg_color = bg_color;
 this->fg_color = fg_color;              
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
void StermButton::Draw( bool inverse )
{
 for(int j=0; j<this->stermKey->Get_Label().size(); ++j)
      draw_char( this->screen,
                 this->row,
                 this->col + j,
                 this->stermKey->Get_Label()[j],
                 this->bg_color,
                 this->fg_color,
                 inverse);
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
void StermButton::Select()
{
 this->Draw(true);
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
void StermButton::UnSelect()
{
 this->Draw();
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
string StermButton::Get_Val()
{
 return this->stermKey->Get_Val();
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
string StermButton::Get_Shift_Val()
{
 return this->stermKey->Get_Shift_Val();
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
string StermButton::Get_Ctrl_Val()
{
 return this->stermKey->Get_Ctrl_Val();
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
void StermButton::Set_Bg_Color(int color)
{
 this->bg_color = color;
 this->Draw();
}

//----------------------------------------------------------------------------//
//                                                                            //
//----------------------------------------------------------------------------//
void StermButton::Set_Fg_Color(int color)
{
 this->fg_color = color;
 this->Draw();
}
